package com.zhenti.z1;

public class zhenti_P11 {
    public static void main(String[] args) {
        System.out.println(-2%3);

    }

    //二分法
    public static int minWaitingTime(int[] arr,int m){
        if (arr == null || arr.length == 0)
            return -1;
        int worse = 0;
        for (int i : arr) {
            worse = Math.max(i,worse);
        }
        int  left = 0;
        int right =  worse * m;
        int mid = 0;
        int near = 0;
        while (left <= right){
            mid = (left + right) /2;
            int cover = 0;
            for (int num : arr) {
                cover += (mid/num) +1;
            }
            if (cover >= m + 1){
                near = mid;
                right = mid - 1;
            }else{
                left = mid + 1;
            }
        }
        return near;
    }

    //小根堆









    public static int MinWaitingTime(int[] arr, int m){
        if (arr == null || arr.length == 0 )
            return -1;
        int worse = 0;
        for (int i : arr) {
            worse = Math.max(i, worse);
        }
        int left = 0;
        int right = worse * m;
        int mid = 0;
        int cover = 0;
        while (left <= right){
            mid = (left + right) / 2;
            int t = 0;
            for (int i : arr) {
                t += mid /i +  1;
            }
            if (t >= m){
                cover = mid;
                right = mid - 1;
            }else {
                left = mid + 1;
            }
        }
        return cover;
    }

}
